import com.wyl.dao.UserMapper
import com.wyl.service.user.UserService
import com.wyl.service.user.UserServiceImpl
import com.wyl.utils.getSqlSession
import org.junit.Test

class UserMapperTest {
    @Test
    fun testGetUserByUserCodeAndPwd() {
        getSqlSession().use {
            println(
                it.getMapper(UserMapper::class.java).getUserByUserCode("liming")
            )
        }
    }

    @Test
    fun testLogin() {
        val userService: UserService = UserServiceImpl()
        println(userService.login("admin", "1234567"))
    }

    @Test
    fun testUpdatePwd() {
        getSqlSession().use {
            println(
                it.getMapper(UserMapper::class.java).updatePwd(5, "0000000")
            )
            it.commit()
        }
    }

    @Test
    fun testGetUserCount() {
        getSqlSession().use {
            println(
                it.getMapper(UserMapper::class.java).getUserCount("王", null)
            )
        }
    }

    @Test
    fun testGetUserList() {
        getSqlSession().use {
            it.getMapper(UserMapper::class.java)
                .getUserList(null, null, 0, 5)
                .forEach(::println)
        }
    }
}